import { http } from "@/utils/http";
import { Result } from "../types";

export type menuData = {
  Id?: number,
  ParentId: number,
  Name: string,
  pageurl: string,
  Code: string | number,
  apiurl: string,
  Icon: string,
  Sequence: number,
  Status: number,
  Type: number
};

// 获取所有菜单权限 树状
export const getMenuTreeList = () => {
  return http.request<Result>("get", "/api/Menu/MenuTreeAllList", {});
};

// 新增菜单
export const addMenu = (data: menuData) => {
  return http.request<Result>("post", "/api/Menu/Add", { data });
};

// 修改菜单
export const updateMenu = (data: menuData) => {
  return http.request<Result>("post", `/api/Menu/Update/${data.Id}`, { data });
};

// 删除菜单
export const deleteMenu = (Id: number) => {
  return http.request<Result>("post", `/api/Menu/Delete/${Id}`, {});
};

// 获取当前登录用户的菜单权限 列表
export const getCurrentUserMenuList = () => {
  return http.request<Result>("get", "/api/ListRight", {});
};

//获取当前登录用户的菜单权限 树状
export const getCurrentUserMenuTree = () => {
  return http.request<Result>("get", "/api/Menu/MenuTreeList", {});
};
